class Admin::FrequentAsksController < Admin::ApplicationController
  before_action :set_frequent_ask, only: [:show, :edit, :update, :destroy]

  # GET /admin/frequent_asks
  def index
    @frequent_asks = FrequentAsk.all
  end

  # GET /admin/frequent_asks/1
  def show
  end

  # GET /admin/frequent_asks/new
  def new
    @frequent_ask = FrequentAsk.new(admin_user_id: current_admin_user_id, company_id: current_company_id)
  end

  # GET /admin/frequent_asks/1/edit
  def edit
  end

  # POST /admin/frequent_asks
  def create
    @frequent_ask = FrequentAsk.new(frequent_ask_params)

    if @frequent_ask.save
      redirect_to [:admin, @frequent_ask], notice: 'Frequent ask was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /admin/frequent_asks/1
  def update
    if @frequent_ask.update(frequent_ask_params)
      redirect_to [:admin, @frequent_ask], notice: 'Frequent ask was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /admin/frequent_asks/1
  def destroy
    @frequent_ask.destroy
    redirect_to admin_frequent_asks_url, notice: 'Frequent ask was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_frequent_ask
      @frequent_ask = FrequentAsk.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def frequent_ask_params
      params.require(:frequent_ask).permit(:title, :content, :admin_user_id, :company_id)
    end
end
